#include "delay.h"


void delay_us(uint16_t us)
{
    SysTick->LOAD = us * 168;
    SysTick->VAL = 0x00;
    SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
    while (!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk));
    SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}

//void delay_us(uint16_t us)
//{
//		for (uint8_t i = 0; i < 40; i++);
//}

void delay_ms(uint16_t ms)
{
    while (ms--)
    {
        delay_us(1000);
    }
}

